home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr25
/
gnuplsrc.zip
/
WINEXTRA.C
< prev
Wrap
C/C++ Source or Header
|
1993-03-21
|
5KB
|
156 lines
#ifdef INCRCSDATA
static char RCSid[]="$Id: winextra.c,v 1.2 1992/07/26 12:37:10 fearick Exp fearick $" ;
#endif
/* winextra.c -- some functions that should have been in os/2 1.2,1.3 */
/*
Copyright (c) 1992, Roger Fearick.
All rights reserved
THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT WARRANTIES OF ANY KIND.
Permission is hereby granted for personal, non-commercial use of this
software.You are granted the right to use, modify, and redistribute
it for for non-commercial purposes, provided that all copyright
notices remain intact and all changes are clearly documented.
THE AUTHOR MAKES NO WARRANTY OF ANY KIND WITH RESPECT TO THIS PRODUCT
AND EXPLICITLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY
OR FITNESS FOR ANY PARTICULAR PURPOSE.
*/
/* Update Log
**
* $Log: winextra.c,v $
* Revision 1.2 1992/07/26 12:37:10 fearick
* Initial 32-bit version
*
* Revision 1.1 1992/07/25 15:44:54 fearick
* Initial revision
*
*
*/
#define INCL_PM
#define INCL_WIN
#include <os2.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
extern HWND hwndFrame ; /* sometime, change so this is arg, or other, ...*/
void ChangeCheck( HWND, USHORT, USHORT ) ;
void ChangeGrey( HWND, USHORT, USHORT ) ;
void WinSetDlgItemLong( HWND, USHORT, ULONG, BOOL ) ;
void WinSetDlgItemFloat( HWND, USHORT, float ) ;
void WinSetDlgItemFloatF( HWND, USHORT, int, float ) ;
void WinQueryDlgItemFloat( HWND, USHORT, float* ) ;
void ChangeCheck( HWND hWnd , USHORT wItem1 , USHORT wItem2 )
/*
** Utility function:
**
** move check mark from menu item 1 to item 2
*/
{
HWND hMenu ;
hMenu = WinWindowFromID( hwndFrame, FID_MENU ) ;
if( wItem1 != 0 )
WinSendMsg( hMenu,
MM_SETITEMATTR,
MPFROM2SHORT( wItem1, TRUE ),
MPFROM2SHORT( MIA_CHECKED, 0 ) ) ;
if( wItem2 != 0 )
WinSendMsg( hMenu,
MM_SETITEMATTR,
MPFROM2SHORT( wItem2, TRUE ),
MPFROM2SHORT( MIA_CHECKED, MIA_CHECKED ) ) ;
}
void ChangeGrey( HWND hwnd, USHORT iItem, USHORT iState )
/*
** Change greyed state of menu item iMenu
** State may be 0 or MIA_DISABLED
*/
{
HWND hMenu ;
hMenu = WinWindowFromID( hwndFrame, FID_MENU ) ;
WinSendMsg( hMenu,
MM_SETITEMATTR,
MPFROM2SHORT( iItem, TRUE ),
MPFROM2SHORT( MIA_DISABLED, iState ) ) ;
}
void WinSetDlgItemLong( HWND hwnd, USHORT usID, ULONG ulValue, BOOL bSign )
/*
** A function microsoft forgot ( in v1.1) , see WinSet...Short
*/
{
char achBuffer [ 34 ] ; // default string field size ...
if( bSign ) sprintf(achBuffer, "%ld", ulValue );
else sprintf(achBuffer, "%uld", ulValue );
WinSetDlgItemText( hwnd, usID, achBuffer ) ;
}
void WinSetDlgItemFloatF( HWND hwnd, USHORT usID, int nDec, float flValue )
/*
** A function microsoft forgot ( in v1.1) , see WinSet...Short
*/
{
char achBuffer [ 34 ], *szCvt ; // default string field size ...
int iDec ;
int iSign ;
#ifdef NEVER
szCvt = fcvt( (double)flValue, nDec, &iDec, &iSign ) ;
achBuffer[0] = '\0' ;
if( iSign != 0 ) strcat( achBuffer, "-" ) ;
if( iDec > 0 )
strncat( achBuffer, szCvt, iDec ) ;
else
strcat( achBuffer, "0" ) ;
strcat( achBuffer, "." ) ;
if( iDec < 0 )
for( iSign = -iDec ; iSign > 0 ; iSign-- ) strcat( achBuffer, "0" ) ;
strcat( achBuffer, szCvt+(iDec>0?iDec:0) ) ;
#endif
char fmt[10] ;
sprintf( fmt, "%%12.%df", nDec ) ;
sprintf( achBuffer, fmt, flValue ) ;
WinSetDlgItemText( hwnd, usID, achBuffer ) ;
}
void WinSetDlgItemFloat( HWND hwnd, USHORT usID, float flValue )
/*
** A function microsoft forgot ( in v1.1) , see WinSet...Short
*/
{
char achBuffer [ 34 ] ; // default string field size ...
#ifdef NEVER
gcvt( (double)flValue, 4, achBuffer ) ;
#endif
char fmt[10] ;
sprintf( fmt, "%%12.%df", 4 ) ;
sprintf( achBuffer, fmt, flValue ) ;
WinSetDlgItemText( hwnd, usID, achBuffer ) ;
WinSetDlgItemText( hwnd, usID, achBuffer ) ;
}
void WinQueryDlgItemFloat( HWND hwnd, USHORT usID, float *pflValue )
/*
** A function microsoft forgot ( in v1.1) , see WinQ...Short
*/
{
char achBuffer [ 34 ] ; // default string field size ...
ULONG ulTemp ;
WinQueryDlgItemText( hwnd, usID, 34, achBuffer ) ;
*pflValue = (float) atof( achBuffer ) ;
}